package com.ywjg.serviceimp;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ywjg.dao.UserAddressDao;
import com.ywjg.model.UserAddress;
import com.ywjg.service.IUserAddressService;
@Service
public class UserAddressService implements IUserAddressService {
	@Resource
	UserAddressDao userAddressDao;
	
	/* (non-Javadoc)
	 * @see com.ywjg.serviceimp.IUserAddressService#saveUserAddress(com.ywjg.model.UserAddress)
	 */
	public UserAddress saveUserAddress(UserAddress userAddress) {
		return userAddressDao.save(userAddress);
		
	}
	
	
	public UserAddress getOneAddress(int id) {
		return userAddressDao.findOne(id);
		
	}
	
	/* (non-Javadoc)
	 * @see com.ywjg.serviceimp.IUserAddressService#findUserAddress(int)
	 */
	public List<UserAddress> findUserAddress(int userId) {
		return userAddressDao.findByuserId(userId);
		
	}
	
	
	public UserAddress setDefultAddress(int id) {
		 UserAddress address = userAddressDao.findOne(id);
		 address.setIsDefult(1);
		 UserAddress save = userAddressDao.save(address);
		 return save;
		
	}
	
	
	public void deleteAddress(int id) {
		 userAddressDao.delete(id);
		
	}
	
	
	
	
	
	
}
